package com.suse.warmstill.controller;

import com.suse.warmstill.entity.TbPeerAssistance;
import com.suse.warmstill.common.model.CallResult;
import com.suse.warmstill.mapper.TbPeerAssistanceMapper;
import com.suse.warmstill.service.ITbPeerAssistanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author 黄靖
 * @author 2023-03-04 09:48
 * description:
 **/
@RestController
@Api(tags = "pc的朋辈互助管理 ok")
@RequestMapping("pc/peerAssistance")
public class PcPeerAssistanceApi {
    @Resource
    private ITbPeerAssistanceService peerAssistanceService;

    @Resource
    private TbPeerAssistanceMapper mapper;




    @ApiOperation("查看所有的 api")
    @GetMapping("/list")
    public CallResult list(){

        return CallResult.success(peerAssistanceService.list());
    }

    @ApiOperation("删除")
    @GetMapping
    @Transactional
    public CallResult delete(Integer id){
        return CallResult.success(mapper.deleteById(id));
    }

    @ApiOperation("新增")
    @PostMapping("insert")
    public CallResult insert(@RequestBody TbPeerAssistance peerAssistance){
        return CallResult.success(mapper.insert(peerAssistance));
    }

    @ApiOperation("新增,需要传id")
    @PostMapping("edit")
    public CallResult edit(@RequestBody TbPeerAssistance peerAssistance){
        return CallResult.success(mapper.updateById(peerAssistance));
    }






}
